

* FIGURE 4

* Create a new folder in the data folder that is named "estimates"

cd "$data"
use "panel.dta", clear 


xtset id vague 


******* Labour estimates 
cd "$data/estimates"

eststo m1: xtreg leftRightW i.vague if pid6==2, fe
margins, at(vague=(1 2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results1, replace)

use results1.dta, clear

gen categories = 1 // labour partisans 

save results1.dta, replace 


******* Conservative estimates 

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"
xtset id vague 

eststo m1: xtreg leftRightW i.vague if pid6==1, fe
margins, at(vague=(1 2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results2, replace)

use results2.dta, clear

gen categories = 2 // convservative partisans 

save results2.dta, replace 


******* independent estimates 

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg leftRightW i.vague if pid6==0, fe
margins, at(vague=(1 2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 19 20 21 22 23)) saving(results3, replace)

use results3.dta, clear

gen categories = 3 // independent

save results3.dta, replace 

 

******* labour party's perceived position by labour partisans 
* waves 13, 14, and 19 are not available for this DV

cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrLabW i.vague if pid6==2, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results4, replace)

use results4.dta, clear

gen categories = 4 // labour party by labour partisans 

save results4.dta, replace 

 
 
******* conservative party's perceived position by conservative identifiers 
* waves 13, 14, and 19 are not available for this DV


cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrConW i.vague if pid6==1, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results5, replace)

use results5.dta, clear

gen categories = 5 // conservative party's perceived position by conservative partisans

save results5.dta, replace  
 
 
 ******* labour party's perceived position by conservative identifiers 
* waves 13, 14, and 19 are not available for this DV


cd "$data"
use "panel.dta", clear 
cd "$data/estimates"

xtset id vague 

eststo m1: xtreg lrLabW i.vague if pid6==1, fe
margins, at(vague=(2 3 4 5 6 7 8 9 10 11 12 15 16 17 18 20 21 22 23)) saving(results6, replace)

use results6.dta, clear

gen categories = 6 // labour party's perceived position by conservative partisans

save results6.dta, replace  
 
 
 
*now append these datasets 
 
cd "$data/estimates"
use "results1.dta", clear 
append using "results2.dta"
append using "results3.dta"
append using "results4.dta"
append using "results5.dta"
append using "results6.dta"

drop _deriv _term _predict _se_margin _statistic _pvalue 

rename _margin b
rename _ci_lb b_lower 
rename _ci_ub b_upper 
rename _at vague_updated // note that wave 1, 13, 14 and 19 are not available. Margins command will jump those and will not show them, the outcome will be as if there is no gaps from 1 to the last, hence use "_at1" variable. 


rename categories category


tsset category _at1 
 
twoway (tsline b if category==3, lcolor(gs7%100) lpattern(dash)) (tsline b_lower if category==3, lcolor(gs7%100) lpattern(solid)) (tsline b_upper if category==3, lcolor(gs7%100)) (tsline b if category==1, lcolor(cranberry%100) lpattern(dash)) (tsline b_lower if category==1, lcolor(cranberry%100) lpattern(solid)) (tsline b_upper if category==1, lcolor(cranberry%100) lpattern(solid)) (tsline b if category==4, lcolor(cranberry%50) lpattern(shortdash)) (tsline b_lower if category==4, lcolor(cranberry%50) lpattern(solid)) (tsline b_upper if category==4, lcolor(cranberry%50) lpattern(solid)) , legend(off) xline(6.5, lpattern(solid) lcolor(gs6%70)) tlabel(#30, labels labsize(vsmall) angle(vertical) valuelabel) ttitle("") graphregion(margin(5 5 15 5)) title("(a) Labour identifiers") yscale(range(0(2)8)) ytick(0 2 4 6 8) ylabel(0 2 4 6 8)  
graph save "${figures}/Figure4a.gph",replace 


twoway (tsline b if category==2, lcolor(navy%100) lpattern(dash)) (tsline b_lower if category==2, lcolor(navy%100) lpattern(solid)) (tsline b_upper if category==2, lcolor(navy%100) lpattern(solid)) (tsline b if category==5, lcolor(navy%50) lpattern(shortdash)) (tsline b_lower if category==5, lcolor(navy%50) lpattern(solid)) (tsline b_upper if category==5 , lcolor(navy%50) lpattern(solid))  (tsline b if category==6, lcolor(cranberry%50) lpattern(shortdash)) (tsline b_lower if category==6, lcolor(cranberry%50) lpattern(solid)) (tsline b_upper if category==6, lcolor(cranberry%50) lpattern(solid))  , legend(off) xline(6.5, lpattern(solid) lcolor(gs6%70)) tlabel(#30, labels labsize(vsmall) angle(vertical) valuelabel) xtitle("") graphregion(margin(5 5 15 5)) title("(b) Conservative identifiers") ytitle("")

graph save "${figures}/Figure4b.gph",replace 

cd "$figures"

graph combine "Figure4a.gph" "Figure4b.gph", ycommon xsize(15) ysize(17) row(2)
graph save "${figures}/Figure4.gph", replace 



